/*
 * Copyright (C) 2017 Pingan, Inc. All Rights Reserved.
 */

package com.pingan.haofang.searchcloud.es.api;

import com.pingan.haofang.searchcloud.api.CollectionConfigManager;
import com.pingan.haofang.searchcloud.api.constants.EngineType;
import com.pingan.haofang.searchcloud.api.schema.IndexSchema;
import com.pingan.haofang.searchcloud.es.schema.TemplateManageService;
import com.pingan.haofang.searchcloud.es.utils.EsUtils;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * es的配置管理
 *
 * @author zhangbi617
 * @date 2017-07-17
 */
@Component
public class EsCollectionConfigManagerImpl implements CollectionConfigManager {

    @Autowired
    private TemplateManageService templateManageService;

    @Override
    public EngineType getEngineType() {
        return EngineType.ES;
    }

    @Override
    public boolean create(String clusterHost, IndexSchema schema, String configNameInStorage) {

        return templateManageService.create(clusterHost, schema, EsUtils.nameWithPrefix(configNameInStorage));
    }

    @Override
    public boolean delete(String clusterHost, String configNameInStorage) {
        return templateManageService.delete(clusterHost, EsUtils.nameWithPrefix(configNameInStorage));
    }

    @Override
    public List<String> getAllConfigNames(String clusterHost) {
        return new ArrayList<String>();
    }
}
